//-----------------------------------------------------------------------
//<copyright file="AccountBLL.cs
//Code gen by tool.
//</copyright>
//-----------------------------------------------------------------------
using System;
using PMS.Exceptions;
using System.Collections.Generic;
using PMS.DAL;
using PMS.Entity;

namespace PMS.BLL
{
	public class AccountBO : BaseBO
	{
		// Interface Instant Object
		private readonly IAccountDAO accountInterfaceObject = null;

		// Constructor
		public AccountBO()
		{
			accountInterfaceObject = new DAL.ServiceFactory<IAccountDAO>().CurrentDAL;
		}

		#region Account

		/// <summary>
		///
		/// </summary>
		/// <param name="account"></param>
		public Account CreateAccount(Account account)
		{
			try
			{
				return accountInterfaceObject.CreateAccount(account);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access CreateAccount Exception", ex);
			}
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="account"></param>
		public void UpdateAccount(Account account)
		{
			try
			{
				accountInterfaceObject.UpdateAccount(account);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access UpdateAccountException", ex);
			}
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="account"></param>
        public void ChangePassword(string ID,String NewPass)
        {
            try
            {
                accountInterfaceObject.ChangePasswprd(ID,NewPass);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access UpdateAccountException", ex);
            }
        }


		/// <summary>
		///
		/// </summary>
		/// <param name="account"></param>
		public void DeleteAccount(Account account)
		{
			try
			{
				accountInterfaceObject.DeleteAccount(account);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access DeleteAccountException", ex);
			}
		}

		/// <summary>
		///
		/// </summary>
		public Accounts GetAllAccount()
		{
			try
			{
				return accountInterfaceObject.GetAllAccount();
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access GetAllAccount Exception", ex);
			}
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="id"></param>
		public Account GetAccountByID(string id)
		{
			try
			{
				return accountInterfaceObject.GetAccountByID(id);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access GetAccountBy ID Exception", ex);
			}
		}

        public Account login(string username, string pass)
        {
            try
            {
                return accountInterfaceObject.loogin(username,pass);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetAccountBy ID Exception", ex);
            }
        }
		#endregion
	}
}
